﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Models.Account.DetailModel>" %>

<%@ Import Namespace="QianBuo.Lottery.Web.Models.Account" %>
<%@ Import Namespace="Code.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    账变明细
    <% TempData["Surrogate_AccountReport_Serch.Type"] = Model.Serch.Type; %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <%if (Request["ReturnUrl"] != null){%>
        <a class="a_blue" href='<%=Request["ReturnUrl"] %>'>&gt;&gt;返回</a>
        <%} %>
        <% Html.DisableClientValidation(); %>
        <% Html.BeginForm(Url.Route(new {ReturnUrl=Request["ReturnUrl"],act=Request["act"],cont=Request["cont"],arst=Request["arst"] }), Url.Route(new { id = "serchreportform" })); %>
        <table class="table" width="100%">
            <tr class="th">
                <th align="left" colspan="6">
                    &nbsp;查找条件
                </th>
            </tr>
            <tr>
                <td>
                    <label for="Serch_Type">类型:</label>
                    <%=Html.DropDownListFor(p=>p.Serch.Type,Model.Types.OrderBy(p=>p.Text.Length).Each(p=>p.Selected=p.Value==Model.Serch.Type.ToString())) %>
                </td>
                <td>
                    <label for="Serch_MinTime">
                        金额:</label>
                    <input type="text" name="Serch.MinMoney" id="Serch_MinMoney" validate="{number:true,range:[0,999999999],messages:{number:'*',range:'*'}}"
                        class="text80" value='<%=Model.Serch.MinMoney %>' />
                </td>
                <td>
                    <label for="Serch_MaxMoney">
                        至:</label>
                    <input type="text" name="Serch.MaxMoney" id="Serch_MaxMoney" validate="{number:true,range:[0,999999999],messages:{number:'*',range:'*'}}"
                        class="text80" value='<%=Model.Serch.MaxMoney %>' />
                </td>
                <td align="center">
                    <label for="Serch.UserType" id="Serch_UserType">用户组:</label>
                    <%=Html.DropDownListFor(p => p.Serch.UserType, Model.UserTypes.Each(p => p.Selected = p.Text.Equals(Model.Serch.UserType)))%>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="Serch_LoginName">用户:</label>
                    <input type="text" name="Serch.LoginName" id="Serch_LoginName" class="text100" value='<%=Model.Serch.LoginName %>' />
                </td>
                <td>
                    <label for="Serch_StartTime">
                        时间:</label>
                    <input type="text" name="Serch.StartTime" id="Serch_StartTime" onclick="WdatePicker()" class="text80" value='<%=Model.Serch.StartTime.ToString("d") %>' />
                </td>
                <td>
                    <label for="Serch_EndTime">
                        至:</label>
                    <input type="text" name="Serch.EndTime" id="Serch_EndTime" onclick="WdatePicker()" class="text80" value='<%=Model.Serch.EndTime.ToString("d") %>' />
                </td>
                <td align="center">
                    <input type="submit" value="查找" />
                </td>
            </tr>
        </table>
        <%=Html.HiddenFor(p=>p.PageSize) %>
        <% Html.EndForm(); %>
        <p />
        <table id="report" class="table" width="100%">
            <tr class="th">
                <th width="10%">用户</th>
                <th width="8%">组</th>
                <th width="18%">日期</th>
                <th width="10%">类型</th>
                <th width="5%">收入</th>
                <th width="5%">支出</th>
                <th width="35%">备注</th>
            </tr>
            <%  if (Model.Details != null && Model.Details.Count() > 0)
            {
                foreach (var item in Model.Details)
                {
                    if (item.Type == UserAccountDetailType.TackMoney)
                        item.Memo = item.Memo == null ? "" : item.Memo.Replace("&&", "管理员说:").Replace("&", "我    说:");%>
            <tr id="tritem">
                <td>
                    <%=Html.ActionLink(item.LoginName, "AccountDetail", new RouteValueDictionary { { "Serch.LoginName", item.LoginName } }, new RouteValueDictionary { {"class","a_blue"}})%></td>
                <td><%=((UserType)item.UserType).GetName() %></td>
                <td><%=string.Format("{0:yyyy-MM-dd HH:mm:ss}",item.AddTime) %></td>
                <td><%=((UserAccountDetailType)item.Type).GetName()%></td>
                <td align="right"><%=item.InMoney.ToString("F") %></td>
                <td align="right"><%=item.OutMoney.ToString("F") %></td>
                    <% 
                        item.Memo = (!string.IsNullOrEmpty(item.Memo) && !string.IsNullOrEmpty(item.StateText) ? item.Memo + "," + item.StateText : item.Memo + item.StateText) ?? "";
                        var str = item.Memo.Length < 32 ? item.Memo : item.Memo.Substring(0, 30) + "...";
                        str = string.IsNullOrEmpty(str) ? "详情" : str;
                        var act = null as string;
                        var menu = new {act =Request["act"]?? "AccountDetail", cont =Request["cont"]?? "Surrogate", arst =Request["arst"] ?? Model.Serch.Type.ToString() };
                        var ReturnUrl = Url.Action("AccountDetail", "Surrogate", Url.Route(new { Model.Serch, Model.PageSize,Model.Page, ReturnUrl = Request["ReturnUrl"] }, menu));
                    
                        switch (item.Type)
                        {
                            //case UserAccountDetailType.Play:
                            //case UserAccountDetailType.WinMoney:
                            //case UserAccountDetailType.WinMoney_Child:
                            //case UserAccountDetailType.BackMoney:
                            //case UserAccountDetailType.QuashScheme:
                            //case UserAccountDetailType.BackMoney_Child:
                                //if(item.StateText==SchemeState.Normal.GetName())
                                //    act = Url.Action( "Detail", "Scheme", Url.Route(new { SchemeID = item.ID, ReturnUrl }, menu));
                                //else
                                //    act = Url.Action("HistoryDetail", "Scheme", Url.Route(new { SchemeID = item.ID, ReturnUrl }, menu));
                                //break;
                            case UserAccountDetailType.Other:
                                if (item.State == ((int)OtherMoneyDetailType.ChaseDetailCancle).ToString() && item.Info.ContainsKey("TaskID"))
                                    act = act = Url.Action("Detail", "ChaseTask", Url.Route(new { ChaseID = item.Info["TaskID"], DetailID = item.ID, ReturnUrl }, menu));
                                else if (item.State == ((int)OtherMoneyDetailType.ChaseTaskCancle).ToString())
                                    act = act = Url.Action("Detail", "ChaseTask", Url.Route(new { ChaseID = item.ID, ReturnUrl }, menu));
                                else if (item.State == ((int)OtherMoneyDetailType.BackTimeOutScheme).ToString())
                                    act = act = Url.Action("HistoryDetail", "Scheme", Url.Route(new { SchemeID = item.ID, ReturnUrl }, menu));
                                break;
                            //case UserAccountDetailType.ChaseTask:
                            //    act = act = Url.Action("Detail", "ChaseTask", Url.Route(new { ChaseID = item.ID, ReturnUrl }, menu));
                            //    break;
                        } %>
                <td align="left" title='<%=item.Memo %>'>
                    <label title='<%=item.Memo %>'><a <%=act == null ? "" : "href='" + act + "' class='a_blue'" %>><%=str %></a></label>
                </td>
            </tr>
            <%} %>
            <tr>
                <td>
                    <font color="red">合计</font>
                </td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td align="right"><%=Model.SumDetail.InMoney.ToString("F")%></td>
                <td align="right"><%=Model.SumDetail.OutMoney.ToString("F")%></td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td colspan="7">
                    <%=Html.Pager(Model.Page.Value, Model.PageSize, Model.SumCount, "Page", Url.Route(new { Model.Serch, Model.PageSize}, new {returnUrl=Request["ReturnUrl"], act = Request["act"], cont = Request["cont"], arst = Request["arst"] }), "PageSize")%>
                </td>
            </tr>
            <%}
            else
            {%>
            <tr>
                <td colspan="9">
                    无记录！
                </td>
            </tr>
            <%} %>
        </table>
        <%if (Request["ReturnUrl"] != null){%>
        <a class="a_blue" href='<%=Request["ReturnUrl"] %>'>&gt;&gt;返回</a>
        <%} %>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
    <script src='<%=Url.Content("~/Scripts/jquery.metadata.js") %>' type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#serchreportform").validate();
            $("#report #tritem:odd").addClass("supersede");
        });

    </script>
</asp:Content>
